package com.qiall.boot.fileservice.impl;

import com.qiall.boot.fileservice.StreamProcessInServer;
import com.qiall.boot.fileservice.data.eitity.enums.FileSourceTypeEnum;
import com.qiall.common.exception.BusinessException;
import com.qiall.common.exception.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class BaseFileServiceProxy {

    @Autowired
    @Qualifier("ossFileService")
    private StreamProcessInServer ossFileService;
    @Autowired
    @Qualifier("minioFileService")
    private StreamProcessInServer minioFileService;

    public StreamProcessInServer getBaseFileService(FileSourceTypeEnum fileSourceTypeEnum ){
         if(fileSourceTypeEnum.equals(FileSourceTypeEnum.OSS)){
             return ossFileService;
         }
         if(fileSourceTypeEnum.equals(FileSourceTypeEnum.MINIO)){
             return minioFileService;
         }
         throw new BusinessException(ResultCode.SYSTEM_ERROR,"file process type not support");
    }
}
